﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CommitteesList.aspx.cs"
    Inherits="Pap.Web.Modules.Administration.Views.CommitteesList" Title="<%$Resources:PageTitle %>"
    MasterPageFile="~/MasterPages/Core.Master" %>

<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <ext:Store runat="server" ID="storeCenters">
        <Reader>
            <ext:JsonReader ReaderID="CenterID">
                <Fields>
                    <ext:RecordField Name="CenterName">
                    </ext:RecordField>
                    <ext:RecordField Name="CenterID">
                    </ext:RecordField>
                    <ext:RecordField Name="Villages">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeCommittees" OnRefreshData="CommitteesGrid_Refreshed">
        <Reader>
            <ext:JsonReader ReaderID="CommitteeID">
                <Fields>
                    <ext:RecordField Name="CommitteeName">
                    </ext:RecordField>
                    <ext:RecordField Name="CommitteeID">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeCenterVillages">
        <Reader>
            <ext:JsonReader ReaderID="VillageID">
                <Fields>
                    <ext:RecordField Name="VillageName">
                    </ext:RecordField>
                    <ext:RecordField Name="VillageID">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeCommitteeVillages">
        <Reader>
            <ext:JsonReader ReaderID="VillageID">
                <Fields>
                    <ext:RecordField Name="VillageName">
                    </ext:RecordField>
                    <ext:RecordField Name="VillageID">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeProjects">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="ProjectID" />
                    <ext:RecordField Name="ProjectName" />
                    <ext:RecordField Name="AccountNumber" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout ID="FitLayout" runat="server">
        <ext:GridPanel runat="server" ID="grvCommittees" StoreID="storeCommittees" Title="<% $Resources:CommitteesListTitle %>"
            TrackMouseOver="true" StripeRows="true" AutoExpandColumn="CommitteeName" Border="true"
            Frame="true">
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="CommitteeName" DataIndex="CommitteeName" Header="<% $Resources:CommitteeNameHeader %>" />
                    <ext:CommandColumn Width="30" Align="Center">
                        <Commands>
                            <ext:GridCommand CommandName="Edit" Icon="NoteEdit" ToolTip-Text="<% $Resources:CommitteeEditToolTip %>" />
                        </Commands>
                    </ext:CommandColumn>
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <AjaxEvents>
                <Command OnEvent="GrvCommittees_Command">
                    <ExtraParams>
                        <ext:Parameter Name="CommandName" Value="command" Mode="Raw" />
                    </ExtraParams>
                </Command>
            </AjaxEvents>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" ID="btnNewCommittee" Text="Add Committee" Icon="Add" meta:resourcekey="btnNewCommitteeResource">
                            <AjaxEvents>
                                <Click OnEvent="BtnNewCommittee_Clicked">
                                </Click>
                            </AjaxEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <BottomBar>
                <ext:PagingToolbar runat="server" StoreID="storeCommittees" PageSize="10" AutoRender="true"
                    AutoDataBind="true" meta:resourcekey="tlbrPagingResource1">
                </ext:PagingToolbar>
            </BottomBar>
        </ext:GridPanel>
    </ext:FitLayout>
    <ext:Window runat="server" ID="wndCommmitteeDetails" Modal="true" ShowOnLoad="false"
        Height="250px" Width="300px" AutoScroll="true" Draggable="false">
        <Body>
            <ext:FormPanel runat="server" ID="panelWindow" IDMode="Static">
                <Defaults>
                    <ext:Parameter Name="Anchor" Value="90%" />
                    <ext:Parameter Name="SelectOnFocus" Value="true" Mode="Raw" />
                    <ext:Parameter Name="IDMode" Value="Static" Mode="Value" />
                </Defaults>
                <Body>
                    <ext:FormLayout runat="server" ID="FormLayout">
                        <ext:Anchor>
                            <ext:TextField runat="server" ID="txtCommitteeName" FieldLabel="<%Resources:CommitteeNameFieldLabel %>"
                                MaxLength="50" AllowBlank="false" meta:resourcekey="txtCommitteeNameResource1" />
                        </ext:Anchor>
                        <ext:Anchor>
                            <ext:ComboBox runat="server" ID="cmbCenters" DisplayField="CenterName" ValueField="CenterID"
                                FieldLabel="<%$Resources:CenterFieldLable %>" StoreID="storeCenters" AllowBlank="false">
                                <AjaxEvents>
                                    <Select OnEvent="CmbCenters_Select">
                                        <EventMask ShowMask="true" />
                                    </Select>
                                </AjaxEvents>
                            </ext:ComboBox>
                        </ext:Anchor>
                        <ext:Anchor>
                            <ext:GridPanel runat="server" ID="grvCenterVillages" StoreID="storeCenterVillages"
                                AutoWidth="true" AutoHeight="true" TrackMouseOver="true" StripeRows="true">
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column DataIndex="VillageName" Header="<% $Resources:VillageNameHeader %>" />
                                        <ext:CommandColumn>
                                            <Commands>
                                                <ext:GridCommand CommandName="Add" Icon="Add" ToolTip-Text="<% $Resources:AddVillageToolTip %>" />
                                            </Commands>
                                        </ext:CommandColumn>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                                </SelectionModel>
                                <AjaxEvents>
                                    <Command OnEvent="GrvCenterVillages_Command">
                                        <ExtraParams>
                                            <ext:Parameter Name="CommandName" Value="command" Mode="Raw" />
                                            <ext:Parameter Name="ID" Value="record.data.VillageID" Mode="Raw" />
                                        </ExtraParams>
                                    </Command>
                                </AjaxEvents>
                            </ext:GridPanel>
                        </ext:Anchor>
                        <ext:Anchor>
                            <ext:GridPanel runat="server" ID="grvCommitteeVillages" StoreID="storeCommitteeVillages"
                                AutoWidth="true" AutoHeight="true" TrackMouseOver="true" StripeRows="true">
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column DataIndex="VillageName" Header="<% $Resources:VillageNameHeader %>" />
                                        <ext:CommandColumn>
                                            <Commands>
                                                <ext:GridCommand CommandName="Remove" Icon="Delete" ToolTip-Text="<% $Resources:RemoveVillageToolTip %>" />
                                            </Commands>
                                        </ext:CommandColumn>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" />
                                </SelectionModel>
                                <AjaxEvents>
                                    <Command OnEvent="GrvCommitteeVillages_Command">
                                        <ExtraParams>
                                            <ext:Parameter Name="ID" Value="record.data.VillageID" Mode="Raw" />
                                            <ext:Parameter Name="CommandName" Value="command" Mode="Raw" />
                                        </ExtraParams>
                                    </Command>
                                </AjaxEvents>
                            </ext:GridPanel>
                        </ext:Anchor>
                        <ext:Anchor>
                            <ext:GridPanel runat="server" ID="gridProjectsBankAccounts" StoreID="storeProjects"
                                AutoWidth="true" AutoHeight="true" TrackMouseOver="true" StripeRows="true">
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column DataIndex="ProjectName" Header="<%$Resources:ProjectHeader %>" />
                                        <ext:Column DataIndex="AccountNumber" Header="<%$Resources:AccountNumberHeader %>">
                                            <Editor>
                                                <ext:NumberField runat="server" ID="txtAccountNumber" IDMode="Static" AllowBlank="false"
                                                    AllowNegative="true" MinLength="1" Text="11111">
                                                </ext:NumberField>
                                            </Editor>
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:RowSelectionModel runat="server" />
                                </SelectionModel>
                            </ext:GridPanel>
                        </ext:Anchor>
                    </ext:FormLayout>
                    <asp:CustomValidator runat="server" ControlToValidate="txtCommitteeName" OnServerValidate="txtCommitteeName_Validate" />
                </Body>
            </ext:FormPanel>
        </Body>
        <BottomBar>
            <ext:StatusBar ID="StatusBar1" runat="server">
                <Items>
                    <quadz:CoolitePermitButton runat="server" ID="btnSaveComittee" meta:resourcekey="btnSaveComitteeResource1"
                        PermissionName="SaveCommitteeList" HideAsDisabled="true">
                        <AjaxEvents>
                            <Click OnEvent="BtnSaveComittee_Clicked" Before="debugger; var valid= #{panelWindow}.getForm().isValid(); return valid;">
                                <EventMask Msg="Saving" />
                                <ExtraParams>
                                    <ext:Parameter Name="gridProjectData" Value="Ext.encode(#{gridProjectsBankAccounts}.getRowsValues(false))"
                                        Mode="Raw" />
                                </ExtraParams>
                            </Click>
                        </AjaxEvents>
                    </quadz:CoolitePermitButton>
                </Items>
            </ext:StatusBar>
        </BottomBar>
    </ext:Window>
</asp:Content>
